package com.ly.controller;

import com.ly.service.PaymentService;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@RequestMapping("payment")
@RestController
public class PaymentController {

    @Resource
    private PaymentService paymentService;

    @Value("${server.port}")
    private String serverPort;

    @GetMapping(value = "/hystrix/ok/{id}")
    public String paymentInfo_ok(@PathVariable String id) {
        return paymentService.paymentInfo(id);
    }

    @GetMapping(value = "/hystrix/false/{id}")
    public String getPaymentInfoFalse(@PathVariable String id) {
        return paymentService.paymentInfoFalse(id);
    }

    /**
     * 服务熔断
     * @param id
     * @return
     */
    @GetMapping(value = "/hystrix/circuit")
    public String paymentCircuitBreaker(String id) {
        return paymentService.paymentCircuitBreaker(id);
    }

}
